<!DOCTYPE html>
<html>
<head>
  <meta charset="UTF-8">
  <title>Document</title>
  <script src="jquery-3.6.0.min.js"></script>
</head>
<body>
  <div>
    <p>我是标题1</p>
    <p>我是标题2</p>
    <p>我是标题3</p>
  </div>
  <script>
    $('div p:eq(1)').replaceWith('<b>我是标题2</b>')
  </script>
</body>
</html>